package JavaSEAdvance.day10_MapAndStream;

import java.util.*;
import java.util.stream.Stream;

/**
 * @author Xiao
 * @date 2021/7/28
 */
public class D10_3StreamDemo {
    /**
     * Stream流的获取方法
     */
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>(List.of("a", "b", "c"));
        list.stream().forEach(s -> System.out.println(s));
        System.out.println("------------");
        HashMap<String, Integer> hm = new HashMap<>();
        hm.put("zhangsan", 23);
        hm.put("lisi", 24);
        hm.put("wangwu", 25);
        hm.entrySet().stream().forEach(entry -> System.out.println(entry.getKey() + "\t" + entry.getValue()));
        hm.keySet().stream().forEach(s -> System.out.println(s));
        hm.values().stream().forEach(s -> System.out.println(s));
        System.out.println("------------");
        Integer[] arr = {1, 3, 5, 7, 9};
        Arrays.stream(arr).forEach(s -> System.out.println(s));
        System.out.println("------------");
        Stream.of("aa", "bb", "cc").forEach(s -> System.out.println(s));
    }
    public static void method(){
        HashMap<String,Integer> hm = new HashMap<>();
        hm.put("aa", 11);
        hm.put("bb", 22);
        hm.put("cc", 33);
        Collection<Integer> values = hm.values();
        System.out.println(values); //[11, 22, 33]
    }
}
